package neu.soft.constant;


import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

import java.util.Objects;

@Getter
public enum TaskOrderStatus implements BaseEnum{
    Ready_To_Distribute (0,"可分配"),
    Out_Of_Center_WareHouse (1,"可调度"),
    Arrive_Distribution_Station(2,"已领货") ,
    Have_Distributed (3,"已分配"),
    Picked_By_Deliveryman(4,"已领货"),
    Finished_Distribution(5,"完成"),
    Invalid_Order (6,"失败");

    @EnumValue
    private final int code;
    @JsonValue
    private final String value;

    TaskOrderStatus(int code, String value) {
        this.code = code;
        this.value = value;
    }

    //必须重写toString
    @Override
    public String toString() {
        return this.value;
    }

    @JsonCreator
    public static TaskOrderStatus getItem(String value){
        for(TaskOrderStatus item : values()){
            if(Objects.equals(item.getValue(), value)){
                return item;
            }
        }
        return null;
    }
}
